package cn.yusei.teamTribe.dao.team;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.yusei.teamTribe.dao.team.po.TeamVideoPO;

@Mapper
public interface TeamVideoDAO {

	final String TEAM_VIDEO_TABLE = " r_video_team_user_album ";
	final String INSERT_FIELDS = " (album_id, team_id, user_id, file_id) ";
	final String SELECT_FIELDS = " albumId, team_id, user_id, file_id, create_time ";
	
	@Insert({"insert into", TEAM_VIDEO_TABLE, INSERT_FIELDS, "values (#{albumId}, #{teamId}, #{userId}, #{fileId})"})
	public void insert(TeamVideoPO TeamVideoPO);
	
	@Select({"select file_id from", TEAM_VIDEO_TABLE, "where deleted = 0 and album_id = #{albumId} and team_id = #{teamId} limit #{offset}, #{num}"})
	public String[] select(@Param("albumId") int albumId, @Param("teamId") int teamId, @Param("offset") int offset, @Param("num") int num);
	
	@Update({"update", TEAM_VIDEO_TABLE, "set deleted = 1 where album_id = #{albumId} and team_id = #{teamId} and user_id = #{userId} and file_id = #{fileId}"})
	public void delete(TeamVideoPO TeamVideoPO);
	
	@Update({"update", TEAM_VIDEO_TABLE, "set deleted = 1 where team_id = #{teamId} and album_id = #{albumId}"})
	void deleteAlbum(@Param("teamId") int teamId, @Param("albumId") int albumId);
}
